$(function(){
	new Vue({
		el:"#memeberListApp",
		data:{
			fullscreenLoading:false,
			searchMember:"",
			currentPage:1,
			totalSize:1,
			tableData: [],
		},
		created:function(){
		   parent.vueData.$data.hreHtml = "../member/index.html";
		   parent.vueData.activeIndex = "2";
		   parent.vueData.getLeftNav("2")
		   parent.vueData.$data.categoryIndex = 0
		   this.getMemberList(1)
		},
		methods:{
			getMemberList(page){
				this.fullscreenLoading = true;
				axios({
					url: POSTURL.getAllUser,
					method: 'post',
					data: {
						page:page,
					}
				}).then(response => {
					this.fullscreenLoading = false;
					if (response.data.code === 100) {
						if (page === 1) {
							if (response.data.result.page <=1) {
								this.totalSize = response.data.result.users.length
							} else {
								this.totalSize = response.data.result.page * 10
							}
							this.tableData.length = 0;
							this.tableData = [];
						}
						this.tableData = this.tableData.concat(response.data.result.users)
					} else {
						this.$message.error(response.data.message);
					}
				}).catch(error => {
					this.fullscreenLoading = false;
					console.log(error);
					this.$message.error('服务器出错!');
				})
			},
			handleCurrentChange(val) {
				 this.getMemberList(val)
			},
			handleDelete(val){
				if(val.state === 1){
					this.$message.error('已被封禁，请联系管理员解封!');
					return
				}
                this.fullscreenLoading = true;
                let param = {
                	data: val.uuid,
                }
                axios({
                	url: POSTURL.delUser,
                	method: 'post',
                	data: param
                }).then(response => {
                	this.fullscreenLoading = false;
                	if (response.data.code === 100) {
                		this.$message({
                			showClose: true,
                			message: response.data.message,
                			type: 'success'
                		});
						 this.getMemberList(1)
                	} else {
                		this.$message.error(response.data.message);
                	}
                }).catch(error => {
                	this.fullscreenLoading = false;
                	console.log(error);
                	this.$message.error('服务器出错!');
                })     
			},
			handleRest(val){
				
				if(val.state === 0){
					this.$message.error('操作无法执行，该账号未被封禁');
					return
				}
				this.fullscreenLoading = true;
				let param = {
					data: val.uuid,
				}
				axios({
					url: POSTURL.relieveUser,
					method: 'post',
					data: param
				}).then(response => {
					this.fullscreenLoading = false;
					if (response.data.code === 100) {
						this.$message({
							showClose: true,
							message: response.data.message,
							type: 'success'
						});
						 this.getMemberList(1)
						
					} else {
						this.$message.error(response.data.message);
					}
				}).catch(error => {
					this.fullscreenLoading = false;
					console.log(error);
					this.$message.error('服务器出错!');
				}) 
			}
		}
	})
})